package com.yx.customized;

import android.graphics.Color;
import android.os.Handler;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.ProgressBar;
import android.widget.TextView;

import com.warkiz.widget.IndicatorSeekBar;
import com.warkiz.widget.OnSeekChangeListener;
import com.warkiz.widget.SeekParams;

/**
 * 测试Activity
 */
public class TestActivity extends AppCompatActivity {

    //弹性ScrollView
    private ElasticScrollView scroll_view;

    //Dialog
    private TextView one, two, three;
    //文字动画
    private AnimateText animationText1, animationText2;

    //滑块https://github.com/warkiz/IndicatorSeekBar

    private IndicatorSeekBar seekbar_a, seekbar_b;
    private ProgressBar progressbar_a, progressbar_b;

    //等级星星
    private LevelView level_view;

    //渐变色圆形进度
    private CircleProgressBar circle_progress_1;
    private RoundProgress socProgress;
    private int[] color1 = new int[]{Color.parseColor("#FF679C"), Color.parseColor("#FF8369")};

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_test);
        //弹性ScrollView
        scroll_view = (ElasticScrollView) findViewById(R.id.scroll_view);

        //显示等待框样式1
        one = (TextView) findViewById(R.id.one);
        one.setOnClickListener(clicks);

        //显示等待框样式2
        two = (TextView) findViewById(R.id.two);
        two.setOnClickListener(clicks);

        //显示等待框样式3
        three = (TextView) findViewById(R.id.three);
        three.setOnClickListener(clicks);


        //文字动画
        animationText1 = (AnimateText) findViewById(R.id.animationText1);
        animationText2 = (AnimateText) findViewById(R.id.animationText2);
        animationText1.setText("999999.99");
        animationText1.startAnimate();//数字动画
        animationText2.startAnimate();//文字动画

        //滑块代码
        inItSeekBar();

        //等级
        level_view = findViewById(R.id.level_view);
        level_view.setLevel(2, false);

        //渐变色进度
        circle_progress_1 = (CircleProgressBar) findViewById(R.id.circle_progress_1);
        circle_progress_1.setMaxStepNum(100);
        circle_progress_1.update(60, 1000);
        circle_progress_1.setProgressColor(color1);

        socProgress = findViewById(R.id.socProgress);
        socProgress.setProgress(100, true);
    }


    private View.OnClickListener clicks = new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            switch (view.getId()) {
                case R.id.one: //等待加载动画1
                    DialogWaitingUtil.showLoading(TestActivity.this);
                    new Handler().postDelayed(new Runnable() {
                        @Override
                        public void run() {
                            //5秒后隐藏
                            DialogWaitingUtil.hidn();
                        }
                    }, 5000);
                    break;
                case R.id.two://等待加载动画2
                    DialogAlternatinglineUtil.showLoading(TestActivity.this);
                    new Handler().postDelayed(new Runnable() {
                        @Override
                        public void run() {
                            //5秒后隐藏
                            DialogAlternatinglineUtil.hidn();
                        }
                    }, 5000);
                    break;
                case R.id.three://等待加载动画3
                    DialogOwUtil.showLoading(TestActivity.this);
                    new Handler().postDelayed(new Runnable() {
                        @Override
                        public void run() {
                            //5秒后隐藏
                            DialogOwUtil.hidn();
                        }
                    }, 5000);
                    break;
            }


        }
    };


    //滑块代码
    private void inItSeekBar() {
        seekbar_a = (IndicatorSeekBar) findViewById(R.id.seekbar_a);
        seekbar_b = (IndicatorSeekBar) findViewById(R.id.seekbar_b);
        progressbar_a = (ProgressBar) findViewById(R.id.progressbar_a);
        progressbar_b = (ProgressBar) findViewById(R.id.progressbar_b);
        seekbar_a.setIndicatorTextFormat("${PROGRESS} %");//带百分比进度指示器
        seekbar_b.setIndicatorTextFormat("${PROGRESS} %");//带百分比进度指示器
        final String TAG = "aaaa";
        //a滑块监听
        seekbar_a.setOnSeekChangeListener(new OnSeekChangeListener() {
            @Override
            public void onSeeking(SeekParams p) {
                Log.i(TAG, p.seekBar + "");
                Log.i(TAG, p.progress + "");
                Log.i(TAG, p.progressFloat + "");
                Log.i(TAG, p.fromUser + "");
                //when tick count > 0
                //Log.i(TAG, p.thumbPosition + "");
                //Log.i(TAG, p.tickText);

                //底部Bar进度
                progressbar_a.setProgress(p.progress);
            }

            @Override
            public void onStartTrackingTouch(IndicatorSeekBar seekBar) {
                Log.i(TAG, "-----开始了-----");
            }

            @Override
            public void onStopTrackingTouch(IndicatorSeekBar seekBar) {
                Log.i(TAG, "-----停止了-----");
            }
        });
        //b滑块监听
        seekbar_b.setOnSeekChangeListener(new OnSeekChangeListener() {
            @Override
            public void onSeeking(SeekParams p) {
                Log.i(TAG, p.seekBar + "");
                Log.i(TAG, p.progress + "");
                Log.i(TAG, p.progressFloat + "");
                Log.i(TAG, p.fromUser + "");
                //when tick count > 0
                //Log.i(TAG, p.thumbPosition + "");
                //Log.i(TAG, p.tickText);
            }

            @Override
            public void onStartTrackingTouch(IndicatorSeekBar seekBar) {
                Log.i(TAG, "-----开始了-----");
            }

            @Override
            public void onStopTrackingTouch(IndicatorSeekBar seekBar) {
                Log.i(TAG, "-----停止了-----");
            }
        });

        //自定义每一节的track块颜色
        //seekbar_a.customSectionTrackColor(new ColorCollector() {
        //    @Override
        //    public boolean collectSectionTrackColor(int[] colorIntArr) {
        //        //the length of colorIntArray equals section count ；app:isb_ticks_count="3"
        //        colorIntArr[0] = ContextCompat.getColor(Myapplication.getInstance(),R.color.product_fb6502);//前半段
        //       colorIntArr[1] = Color.parseColor("#ffcb0f");//后半段
        //        return true; //True if apply color , otherwise no change
        //    }
        //});
    }


}
